/*
 * All content copyright http://www.j2eefast.com, unless
 * otherwise indicated. All rights reserved.
 * No deletion without permission
 */
package com.j2eefast.web.controller;

import com.j2eefast.common.core.business.annotaion.BussinessLog;
import com.j2eefast.common.core.enums.BusinessType;
import com.j2eefast.common.core.utils.*;
import com.j2eefast.framework.annotation.RepeatSubmit;
import com.j2eefast.common.core.controller.BaseController;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.ui.ModelMap;
import java.util.Map;
import org.springframework.web.bind.annotation.*;
import com.j2eefast.web.entity.ItemSkuPriceEntity;
import com.j2eefast.web.service.ItemSkuPriceService;

/**
 * 【请填写功能名称】页面控制器
 * @author ZhouZhou
 * @date 2021-06-11 10:29:57
 */
@Controller
@RequestMapping("//price")
public class ItemSkuPriceController extends BaseController{

    private String prefix = "modules//price";

    @Autowired
    private ItemSkuPriceService itemSkuPriceService;

    /**
     * 视图页面
     */
    @RequiresPermissions(":price:view")
    @GetMapping()
    public String price(){
        return prefix + "/price";
    }
    
    /**
     * 页面表格分页查询
     * @param params
     * @param itemSkuPriceEntity
     * @return
     */
    @RequiresPermissions(":price:list")
    @RequestMapping(value = "/list", method = RequestMethod.POST)
    @ResponseBody
    public ResponseData list(@RequestParam Map<String, Object> params,ItemSkuPriceEntity itemSkuPriceEntity) {
        PageUtil page = itemSkuPriceService.findPage(params,itemSkuPriceEntity);
		return success(page);
    }

    /**
     * 新增视图
     * @param mmap
     * @return
     */
    @GetMapping("/add")
    public String add(){
        return prefix + "/add";
    }

    /**
     * 新增
     */
    @RepeatSubmit
    @RequiresPermissions(":price:add")
    @BussinessLog(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    @ResponseBody
    public ResponseData addItemSkuPrice(@Validated ItemSkuPriceEntity itemSkuPrice){
        //校验参数
        ValidatorUtil.validateEntity(itemSkuPrice);
        return itemSkuPriceService.addItemSkuPrice(itemSkuPrice)? success(): error("新增失败!");
    }

    /**
     * 修改
     */
    @RequiresPermissions(":price:edit")
    @GetMapping("/edit/{pkId}")
    public String edit(@PathVariable("pkId") Long pkId, ModelMap mmap){
        ItemSkuPriceEntity itemSkuPrice = itemSkuPriceService.findItemSkuPriceById(pkId);
        mmap.put("itemSkuPrice", itemSkuPrice);
        return prefix + "/edit";
    }

    /**
     * 修改保存【请填写功能名称】
     */
    @RepeatSubmit
    @RequiresPermissions(":price:edit")
    @BussinessLog(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @RequestMapping(value = "/edit", method = RequestMethod.POST)
    @ResponseBody
    public ResponseData editItemSkuPrice(ItemSkuPriceEntity itemSkuPrice){
        //校验参数
		ValidatorUtil.validateEntity(itemSkuPrice);
        return itemSkuPriceService.updateItemSkuPriceById(itemSkuPrice)? success(): error("修改失败!");
    }

    /**
     * 删除
     */
    @RepeatSubmit
    @RequiresPermissions(":price:del")
    @BussinessLog(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
    @RequestMapping(value = "/del", method = RequestMethod.POST)
    @ResponseBody
    public ResponseData del(Long[] ids) {
      return itemSkuPriceService.deleteBatchByIds(ids)? success(): error("删除失败!");
    }

}
